package com.gupaowork.pattern.adapter;

import java.util.Map;

public class AdapterClient {
    public static void main(String[] args) {
        //使用旧接口功能
        OldService old = new OldServiceImpl();
        Map<String, Object> oldMap = old.getUserInfo("7758520");
        System.out.println("旧接口功能：" + oldMap);

        //使用新接口功能
        NewService nw = new NewServiceImpl();
        Map<String, Object> newMap = nw.getUserInfo("7758520", "18513032646");
        System.out.println("新接口功能：" + newMap);

        //通过适配器，升级后依然兼容旧接口的功能
        InterfaceAdapter adapter = new InterfaceAdapter(old);
        oldMap = adapter.getUserInfo("7758820", "18513032646");
        System.out.println(oldMap);
    }
}
